#ifndef RECVFILECLASS_H
#define RECVFILECLASS_H

#include <QObject>
#include <QTcpSocket>
#include <QDate>
#include <QFile>
#include <QPair>
#include <QDir>
#include "AbstractLayer/MsgHandler/myjson.h"
#include "AbstractLayer/Encipher/encipher.h"
class RecvFileClass : public QObject
{
    Q_OBJECT
public:
    explicit RecvFileClass(QObject *parent = nullptr);
    void initRecvFileClass(const QString& useroc);
    void verify();
    QString checkIsExist(QString filepath,QString filename,QString lastpath);
signals:
    void s_recvNewFile(const QString& friendoc,const QString& content);

private slots:
    void dealRecvFileHead(const QString& senderoc,const unsigned long filesize,const QString& filesha256,const QString& filename);
    void dealFileBlock(const QString& index,const QString& size,const QByteArray& data);
    void sendFileReady();
    void fileEnd();
private:
    QTcpSocket* recvfilesocket;
    QString senderoc;
    QString filename;
    QFile* recvfile;
    unsigned long long totalsize;
    unsigned long long recvdonesize;
    QString useroc;
    QString currentfilepath;
    QString pathdate;
};

#endif // RECVFILECLASS_H
